<?php
if (file_exists("../config.php")){
	include("../config.php");
	if (isset($_POST["username"]) && ($_POST["username"] && $_POST["admpassword"] && $_POST["email"])) {
		$link = mysql_connect($HOST, $USER, $PASS) or die("Error al conectar a la DB");
		mysql_select_db($DB, $link) or die("Error al elegir la db"); 
		importDb("foecms_db.sql", $MYSQL_PREFIX);
		mysql_query("UPDATE ".$MYSQL_PREFIX."config SET value='".$ROOT."' WHERE param LIKE 'php_root'") or die (mysql_error());
		mysql_query("INSERT INTO ".$MYSQL_PREFIX."account (username, pass_sha, email, level) VALUES ('".mysql_real_escape_string($_POST["username"])."','".mysql_real_escape_string(sha1($_POST["admpassword"]))."', '".mysql_real_escape_string($_POST["email"])."', '2');") or die(mysql_error());
		header("location: index.php?stage=4");
	} else include("stage3_style.php");
} else die(header("location: index.php"));
?>